<style type="text/css">
    .main {
        padding: 40px 40px 0 40px;
    }
    .form_datetime input {
    	width: 160px;
    }
    .table .form-control.long {
    	width: 500px;
    }
    .table .form-control.middle {
    	width: 150px;
    }
    .table .form-control.short {
    	width: 100px;
    }
</style>
<div class="main">
    <form method="post" action="/stock/createword" target="_blank">
        <div class="input-append date form_datetime" data-picker-position="bottom-left">
            <input type="text" class="span-2" readonly="" value="  " size="16">
            <span class="add-on"><i class="icon-remove"></i></span>
            <span class="add-on"><i class="icon-th"></i></span>
        </div>
        <?php if(!empty($this->msg)){?>
        <p class="btn btn-danger"><?php echo $this->msg;?></p>
        <?php } ?>
        <div class="table-responsive">
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th>标题</th>
                        <th>条形码</th>
                        <th>尺码</th>
                        <th>数量</th>
                        <th>市场价</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($this->lowstocklogs as $v):?>
                    <tr>
                        <td><input class="form-control long" readonly="readonly" type="text" name="title[]" value="<?php echo $v['title'];?>"></td>
			            <td><input class="form-control middle" readonly="readonly" type="text" name="codename[]" value="<?php echo $v['codename'];?><?php echo date("md");?>"></td>
			            <td><input class="form-control short" readonly="readonly" type="text" name="size[]" value="<?php echo $v['size'];?>"></td>
			            <td><input class="form-control short" type="text" name="num[]" value="<?php echo $v['num'];?>"></td>
			            <td><input class="form-control short" readonly="readonly" type="text" name="price[]" value="<?php echo $v['price'];?>"></td>
		            </tr>
                    <?php endforeach;?>
		        </tbody>
            </table>
        </div>
        <input class="btn btn-warning" type="submit" value="打印生成条形码"> 
    </form>
</div>
<script type="text/javascript">
$(".form_datetime").datetimepicker({
	minView: "month",
	format: "yyyy-mm-dd",
	autoclose: true,
	todayBtn: true,
	language: 'zh-CN',
}).on('changeDate', function(){//日期输入框的值改变时，条形码的值也相应改变
    var date = $(".form_datetime input").val();
    var d = date.split('-');
    if(date == ''){
    
    }else{
    	$('input[name="codename[]"]').each(function(){
    	    var newbarcode = $(this).val();
    	    newbarcode = newbarcode.substr(0,newbarcode.length-4);
        	$(this).val(newbarcode+d[1]+d[2]);
    	});
    }
});
</script>